package com.finstone.data.spider.eshop.service;

import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.Spider.Status;

public abstract class AbstractSpiderService<T> implements ISpiderService<T> {

	protected Spider spider;

	public void init() {

	}

	public void start() {
		spider.start();
	}

	public void stop() {
		spider.stop();
	}

	public void putTask(T object) {
		doPutTask(object);

		if (spider.getStatus() == Status.Stopped) {
			spider.start();
		}
	}

	abstract protected void doPutTask(T object);
}